import request from '../utils/request';
import { mapToParam } from '../utils';

export function fetchVersionPlan({ fixversion_id, project_name, page, pageSize }) {
  return request(`api/searchVersionPlan/?fixversion_id=${fixversion_id}&project_name=${project_name}&page=${page}&pageSize=${pageSize}`, {
    method: 'GET',
    headers: {
      Accept: 'application/json',
      'Content-type': 'application/x-www-form-urlencoded; charset=UTF-8', // 接收x-www-form-urlencoded类型的参数
    },
    // body: JSON.stringify(params),
  });
}
export function addVersionPlan(versionparam) {
  return request('api/addVersionPlan/', {
    method: 'POST',
    headers: {
      Accept: 'application/json',
      'Content-type': 'application/x-www-form-urlencoded; charset=UTF-8',
    },
    body: mapToParam(versionparam),
  });
}
export function updateVersionPlan(versionparam) {
  return request('api/updateVersionPlan/', {
    method: 'POST',
    headers: {
      Accept: 'application/json',
      'Content-type': 'application/x-www-form-urlencoded; charset=UTF-8',
    },
    body: mapToParam(versionparam),
  });
}

export function deleteVersionPlan(recordParams) {
  return request('api/updateVersionPlan/', {
    method: 'POST',
    headers: {
      Accept: 'application/json',
      'Content-type': 'application/x-www-form-urlencoded; charset=UTF-8',
    },
    body: mapToParam(recordParams),
  });
}
export function getVersionAnalysisResult({ fixversion_id, project_name }) {
  return request(`api/getVersionAnalysis/?fixversion_id=${fixversion_id}&project_name=${project_name}`, {
    method: 'GET',
    headers: {
      Accept: 'application/json',
      'Content-type': 'application/x-www-form-urlencoded; charset=UTF-8', // 接收x-www-form-urlencoded类型的参数
    },
  });
}

export function getVersionAnalysisDetail({ jira_fixversion, project_name, storystatus, plan_result }) {
  return request(`api/getVersionAnaDetail/?jira_fixversion=${jira_fixversion}&project_name=${project_name}&storystatus=${storystatus}&plan_result=${plan_result}`, {
    method: 'GET',
    headers: {
      Accept: 'application/json',
      'Content-type': 'application/x-www-form-urlencoded; charset=UTF-8', // 接收x-www-form-urlencoded类型的参数
    },
  });
}

export function getSprintAnalysis({ sprint_id, project_name }) {
  return request(`api/getSprintAnalysis/?sprint_id=${sprint_id}&project_name=${project_name}`, {
    method: 'GET',
    headers: {
      Accept: 'application/json',
      'Content-type': 'application/x-www-form-urlencoded; charset=UTF-8', // 接收x-www-form-urlencoded类型的参数
    },
  });
}

export function getSprintAnaDetail({ sprintid, project_name, storystatus, plan_result }) {
  return request(`api/getSprintAnaDetail/?sprintid=${sprintid}&project_name=${project_name}&storystatus=${storystatus}&plan_result=${plan_result}`, {
    method: 'GET',
    headers: {
      Accept: 'application/json',
      'Content-type': 'application/x-www-form-urlencoded; charset=UTF-8', // 接收x-www-form-urlencoded类型的参数
    },
  });
}

